package day14;

import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int[] arr = new int[n];
            for(int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }
            Arrays.sort(arr);
            System.out.println(dfs(arr, n, 0, 0, 1));

        }
    }
    public static int dfs(int[] a, int n, int pos, int sum, int mul) {
        int count = 0;
        for(int i = pos; i < n; i++) {
            sum += a[i];
            mul *= a[i];
            if(sum > mul) {
                count = count + 1 + dfs(a, n, i + 1, sum, mul);
            }else if(a[i] == 1) {
                count = count + dfs(a, n, i + 1, sum, mul);
            }else {
                break;
            }
            sum -= a[i];
            mul /= a[i];
            while(i < n-1 && a[i] == a[i+1]) {
                i++;
            }
        }
        return count;
    }
}